// 专门用来封装与文章相关的请求
import _fetch from '../utils/request.js'

// 得到面试技巧
export function getTechnicApi (params) {
  return _fetch({
    url: '/articles/technic',
    params: params
  })
}

// 得到市场数据
export function getHotApi () {
  return _fetch({
    url: '/chart-data/hot'
  })
}

// 得到面经分享数据
export function getShareApi (params) {
  return _fetch({
    url: '/articles/share',
    params: params
  })
}

// 得到面经热搜
export function getSearchTopApi () {
  return _fetch({
    url: '/articles/shareTopSearch'
  })
}

// 得到面经详情
export function getShareDetailApi (id) {
  return _fetch({
    url: `/articles/share/${id}`
  })
}

// 得到面经的评论数据
export function getCommentApi ({ id, limit, start }) {
  return _fetch({
    url: `/articles/comments/${id}`,
    method: 'GET',
    params: {
      limit: limit,
      start: start
    }
  })
}

// 添加文章的评论 & 评论的回复
export function setCommentsApi (data) {
  return _fetch({
    url: '/articles/comments',
    method: 'POST',
    needToken: true,
    data: data
  })
}

// 收藏面经分享
export function collectApi (id) {
  return _fetch({
    url: '/articles/collect',
    method: 'POST',
    needToken: true,
    data: {
      id: id
    }
  })
}

// 点赞面经分享
export function starApi (id) {
  return _fetch({
    url: '/articles/star',
    method: 'POST',
    needToken: true,
    data: {
      article: id
    }
  })
}
